<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class commonmodel extends CI_Model { 
    
    public function __construct() {
        parent::__construct();
    }
    
    public function getMenu($parent) {
        $sql = "SELECT a.id, a.label, a.link, Deriv1.Count FROM `menu` a  LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM `menu` GROUP BY parent) Deriv1 ON a.id = Deriv1.parent WHERE a.parent=" . $parent;
        $query = $this->db->query($sql);
        return $query->result();
    }
    
}